#include <bits/stdc++.h>
// 2025/02/06
// tag:
// Author: Zhang Muen
using namespace std;

using int64 = int64_t;

#define int long long

const int maxn = 1001;
int g[maxn][maxn], n, m, h[maxn][maxn], l[maxn][maxn], r[maxn][maxn], L[maxn][maxn], R[maxn][maxn];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n >> m;
    char c;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            cin >> c, g[i][j] = (c == 'F' ? 1 : 0);
    for (int i = 1; i <= n; i++) {
        int last = 0;
        for (int j = 1; j <= m; j++)
            if (g[i][j])
                l[i][j] = last;
            else
                L[i][j] = 0, last = j;
        last = m + 1;
        for (int j = m; j >= 1; j--)
            if (g[i][j])
                r[i][j] = last;
            else
                R[i][j] = m + 1, last = j;
    }
    int ans = 0;
    for (int i = 1; i <= m + 1; i++)
        R[0][i] = m + 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++)
            if (g[i][j]) {
                h[i][j] = h[i - 1][j] + 1;
                L[i][j] = max(l[i][j] + 1, L[i - 1][j]), R[i][j] = min(r[i][j] - 1, R[i - 1][j]);
                ans = max(ans, (R[i][j] - L[i][j] + 1) * h[i][j]);
            }
    cout << ans * 3;
    return 0;
}